﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Net;
using System.Net.Mail;
using Microsoft.SharePoint.Utilities;

/*
Developed By: Bhupender Bindra
Developed On: 2th Dec 2010
Description: The code provides the user to send a mail.   
*/

namespace SiteProjects.Classes
{
    public class Email
    {
        /// <summary>
        /// This function is used to send mail
        /// </summary>
        /// <param name="MailAccount"></param>
        /// <param name="password"></param>
        /// <param name="to"></param>
        /// <param name="subject"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool SendMail(string[] to, string bcc, string cc, string subject, string message)
        {
            bool IsSend = true;

            MailMessage mail = new MailMessage();
            mail.From = new MailAddress(System.Configuration.ConfigurationManager.AppSettings["SendMailAddress"].ToString());
            //For adding all email address
            foreach (string toAddr in to)
                mail.To.Add(new MailAddress(toAddr));
            mail.Subject = subject;
            mail.Body = message;
            mail.IsBodyHtml = true;
            if (!String.IsNullOrEmpty(bcc))
            {
                mail.Bcc.Add(bcc);
            }
            if (!String.IsNullOrEmpty(cc))
            {
                mail.CC.Add(cc);
            }

            SmtpClient client = new SmtpClient();
            try
            {
                client.Send(mail);

            }
            catch
            {
                IsSend = false;
            }
            return IsSend;
        }
        /// <summary>
        /// This function is used to send mail
        /// </summary>
        /// <param name="MailAccount"></param>
        /// <param name="password"></param>
        /// <param name="to"></param>
        /// <param name="subject"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool SendEMail(string[] to, string bcc, string cc, string subject, string message)
        {
            //SPUtility.SendEmail(SPWeb web, true, true, string to, string subject, string htmlBody);
            return true;
        }
    }





}
